import 'package:any_reader/views/chapter/index.dart';
import 'package:any_reader/views/moments/index.dart';

import '../public.dart';

var homeHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  return new BookSheet();
});

var mineHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  return new MinePage();
});

var searchBookHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  return new SearchPage();
});

//String title = Uri.encodeComponent(item.title);
//String url = Uri.encodeComponent(item.originUrl);
//String author = Uri.encodeComponent(item.author);
//String reptileType = Uri.encodeComponent(item.reptileType);
//String reptileType1 = Uri.encodeComponent(item.reptileType1);

var bookInfoHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, dynamic> params) {
  String title = params["title"]?.first;
  String url = params["url"]?.first;
  String author = params["author"]?.first;
  String now = params["now"]?.first;
  String reptileType = params["reptileType"]?.first;
  String reptileType1 = params["reptileType1"]?.first;
  return new BookInfoPage(
    title: title,
    url: url,
    author: author,
    now: now,
    reptileType: reptileType,
    reptileType1: reptileType1,
  );
});

var chapterHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, dynamic> params) {
  String title = params["title"]?.first;
  String url = params["url"]?.first;
  String author = params["author"]?.first;
  String now = params["now"]?.first;
  String reptileType = params["reptileType"]?.first;
  String reptileType1 = params["reptileType1"]?.first;
  return new ChapterPage(
      title: title,
      url: url,
      author: author,
      now: now,
      reptileType: reptileType,
      reptileType1: reptileType1);
});
//final String bookId;
//final String bookName;
//final String author;
//final String rule;
//final String introduction;
//final String tagName;
//final String cover;
//var chapterHandler = new Handler(
//    handlerFunc: (BuildContext context, Map<String, dynamic> params) {
//  String bookId = params["bookId"]?.first;
//  String bookName = params["bookName"]?.first;
//  String author = params["author"]?.first;
//  String rule = params["rule"]?.first;
//  String introduction = params["introduction"]?.first;
//  String tagName = params["tagName"]?.first;
//  String cover = params["cover"]?.first;
//  return new ChapterPage(
//    bookId,
//    bookName,
//    author,
//    rule: rule,
//    introduction: introduction,
//    tagName: tagName,
//    cover: cover,
//  );
//});

//String bookId = Uri.encodeComponent(chapter.bookId);
//String catalogId = Uri.encodeComponent(chapter.catalogId);
//String num = Uri.encodeComponent(chapter.num);
var readerHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, dynamic> params) {
  String bookId = params["bookId"]?.first;
  String catalogId = params["catalogId"]?.first;
  String num = params["num"]?.first;
  String position = params["position"]?.first;
  return new ReaderPage(
    bookId: bookId,
    catalogId: catalogId,
    num: num,
    position: position,
  );
});

var momentsHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, dynamic> params) {
  return new MomentsPage();
});

var retrievalHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, dynamic> params) {
  return new RetrievalPage();
});
